<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>Document</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta content="width=device-width, initial-scale=1" name="viewport"/>
	<meta content="" name="description"/>
	<meta content="" name="author"/>
	<!-- BEGIN GLOBAL MANDATORY STYLES -->
	<link href="./Public/Admin/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
	<link href="./Public/Admin/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css"/>
	<link href="./Public/Admin/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	
	<!-- BEGIN THEME STYLES -->
	<link href="./Public/Admin/assets/global/css/components.css" id="style_components" rel="stylesheet" type="text/css"/>
	
	<link href="./Public/Admin/assets/admin/layout/css/layout.css" rel="stylesheet" type="text/css"/>
	<!--<link href="./Public/Admin/assets/admin/layout/css/themes/darkblue.css" rel="stylesheet" type="text/css" id="style_color"/>-->
	
	<!-- END THEME STYLES -->
	<link rel="shortcut icon" href="favicon.ico"/>
	<!--百度编辑器-->
	<script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="Public/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
    <!--异步上传图片-->
    <script type="text/javascript" src="Public/uploadify/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="Public/uploadify/jquery.uploadify.min.js"></script>
    <link rel="stylesheet" type="text/css" href="Public/uploadify/uploadify.css">
    <script type="text/javascript">
    	$(function(){
    		$('#close_img').click(function(){
    			$(this).parents('#tab1').siblings('.info').css({display:"block"});
    			$(this).parent().remove('td');
    			
    		})
    		$('.close_img1').click(function(){
    			$(this).parents('#tab2').siblings('.info').css({display:"block"});
    			$(this).parent().remove();
    			
    		})
    	})
    </script>
 <base target="iframe"/>
</head>
<body>
	<form action="" method="post" enctype="multipart/form-data">
		<fieldset>
			<legend>修改商品</legend>
			<table class="table table-bordered table-hover">
				<thead>
					<tr>
						<th colspan="2" class="btn btn-primary">基本信息</th>
					</tr>
				</thead>
				<tbody>
					<tr class="info">
						<td>所属分类</td>
						<td>
							<select name="classify_cid">
								<option value="0">-请选择-</option>
								
								{{foreach from="$cate" value="$v"}}
								
								<option value="{{$v['cid']}}" tid="{{$v['type_tid']}}" {{if value="$goodsData[0]['classify_cid']==$v['cid']"}}selected=""{{endif}}>{{$v['_name']}}</option>
								{{endforeach}}
							</select>
						</td>
					</tr>
					<tr class="info">
						<td>所属品牌</td>
						<td>
							<select name="brand_bid">
								<option value="0">-请选择-</option>
								{{foreach from="$brand" value="$v"}}
								<option value="{{$v['bid']}}" {{if value="$goodsData[0]['brand_bid']==$v['bid']"}}selected=""{{endif}}>{{$v['bname']}}</option>
								{{endforeach}}
							</select>
						</td>
					</tr>
					<tr class="info">
						<td>商品名称</td>
						<td>
							<input type="text" name="gname" value="{{$goodsData[0]['gname']}}">
						</td>
					</tr>
					<tr class="info">
						<td>单位</td>
						<td>
							<input type="text" name="gunit" value="{{$goodsData[0]['gunit']}}">
						</td>
					</tr>
					<tr class="info">
						<td>市价场</td>
						<td>
							<input type="text" name="gmprice" value="{{$goodsData[0]['gmprice']}}">
						</td>
					</tr>
					<tr class="info">
						<td>商城价</td>
						<td>
							<input type="text" name="gprice" value="{{$goodsData[0]['gprice']}}">
						</td>
					</tr>
					<tr class="info">
						<td>点击次数</td>
						<td>
							<input type="text" name="gclick" value="{{$goodsData[0]['gclick']}}">
						</td>
					</tr>
				</tbody>
			</table>

			<p class="btn btn-primary">商品属性</p>
			<table class="table table-bordered table-hover" id="attr" class="info">
					{{foreach from="$attrData" value="$v"}}
					{{if value="$v['type'] == 0"}}
					<tr class="info">
					<td>{{$v['attname']}}</td>
					<td>
						<select name="attr[{{$v['taid']}}]" id="">
							<option value="">请选择</option>
							{{foreach from="$v['attvalue']" value="$value"}}
							<option value="{{$value}}" {{if value="$v['gavalue']==$value"}}selected=""{{endif}}>{{$value}}</option>
							{{endforeach}}
						</select>
					</td>
				</tr>
				{{endif}}
				{{endforeach}}
			</table>
			<p class="btn btn-primary">商品规格</p>
			<table class="table table-bordered table-hover" id="spec">
				{{foreach from="$attrData" value="$v"}}
					{{if value="$v['type'] == 1"}}
					<tr class="info">
					<td>{{$v['attname']}}</td>
					<td>
						<select name="spec[{{$v['taid']}}][value][]" id="">
							<option value="">请选择</option>
							{{foreach from="$v['attvalue']" value="$value"}}
							<option value="{{$value}}"{{if value="$v['gavalue']==$value"}}selected=""{{endif}}>{{$value}}</option>
							{{endforeach}}
						</select>
					</td>
					<td>附加价格：<input type="text" name="spec[{{$v['taid']}}][price][]" value="{{$v['addprice']}}"></td>
					<td><span class="btn btn-success add-spec">増加规格</span></td>
				</tr>
				{{endif}}
				{{endforeach}}
			</table>
			{{if value="$goodsData[0]['glistimg']"}}
			<table border="" cellspacing="" cellpadding="" class="table table-bordered" >
				<tr colspan="3" class="btn btn-circle-bottom"><th>列表图</th></tr>
				<tr id="tab1">
					
					
				
					
					
					<td colspan="3">
						<img src="{{$goodsData[0]['glistimg']}}" alt="" style="height:50px;border:1px solid #ccc;border-radius:5px;"/>
						<a href="javascript::" id="close_img">X</a>
						<input type="hidden" name="glistimg" value="{{$goodsData[0]['glistimg']}}"/>
					</td>
					
					
					
					
					
				</tr>
				<tr class="info"style="display: none;">
					<td>上传图片</td>
					<td colspan="2">
						<div lab="uploadFile1">
						    <input id="f1" type="file" multiple="true" name="glistimg">
						    <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
						    <script type="text/javascript">
						        $(function() {
						            $('#f1').uploadify({
						                'formData'     : {//POST数据
						                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
						                },
						                'fileTypeDesc' : '上传文件',//上传描述
						                'fileTypeExts' : '*.jpg;*.png',
						                'swf'      : '{{__PUBLIC__}}/uploadify/uploadify.swf',
						                'uploader' : '{{U('upload')}}',
						                'buttonText':'选择文件',
						                'fileSizeLimit' : '2000KB',
						                'uploadLimit' : 10,//上传文件数
						                'width':65,
						                'height':25,
						                'successTimeout':10,//等待服务器响应时间
						                'removeTimeout' : 0.2,//成功显示时间
						                'onUploadSuccess' : function(file, data, response) {
						                    //转为json
						                    data=$.parseJSON(data);
						                    //获得图片地址
						                    var imageUrl = data.url;
						                    var li="<li><img src='"+imageUrl+"'/><input type='hidden' name='glistimg' value='"+data.path+"'/></li>";
						                    $("#uploadList1 ul").prepend(li);
						                }
						            });
						        });
						    </script>
    						<div id="uploadList1">
      							<ul>

        						</ul>
    						</div>
						</div>
						</td>
				</tr>
			</table>
			{{else}}
			<table class="table table-bordered">
				<tbody>
				<tr>
					<th colspan="3" class="btn btn-primary">列表图</th>
				</tr>
				<tr class="info">
					<td>上传图片</td>
					<td colspan="2">
						<div lab="uploadFile1">
						    <input id="f1" type="file" multiple="true" name="glistimg">
						    <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
						    <script type="text/javascript">
						        $(function() {
						            $('#f1').uploadify({
						                'formData'     : {//POST数据
						                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
						                },
						                'fileTypeDesc' : '上传文件',//上传描述
						                'fileTypeExts' : '*.jpg;*.png',
						                'swf'      : '{{__PUBLIC__}}/uploadify/uploadify.swf',
						                'uploader' : '{{U('upload')}}',
						                'buttonText':'选择文件',
						                'fileSizeLimit' : '2000KB',
						                'uploadLimit' : 10,//上传文件数
						                'width':65,
						                'height':25,
						                'successTimeout':10,//等待服务器响应时间
						                'removeTimeout' : 0.2,//成功显示时间
						                'onUploadSuccess' : function(file, data, response) {
						                    //转为json
						                    data=$.parseJSON(data);
						                    //获得图片地址
						                    var imageUrl = data.url;
						                    var li="<li><img src='"+imageUrl+"'/><input type='hidden' name='glistimg' value='"+data.path+"'/></li>";
						                    $("#uploadList1 ul").prepend(li);
						                }
						            });
						        });
						    </script>
    						<div id="uploadList1">
      							<ul>

        						</ul>
    						</div>
						</div>
						</td>
				</tr>
			</tbody></table>
			{{endif}}
			
			{{if value="$detailData[0]['dimg']"}}
			<table class="table table-bordered">
				<tbody><tr>
					<th colspan="3" class="btn btn-primary">商品图册</th>
				</tr>
				<tr id="tab2">
					{{foreach from="$dimg" value="$v"}}
					<td colspan="3">
						<img src="{{$v}}" alt="" style="height:50px;border:1px solid #ccc;border-radius:5px;"/>
						<a href="javascript::" class="close_img1">X</a>
						<input type="hidden" name="dimg[]" value="{{$v}}"/>
					</td>
					{{endforeach}}
					
				</tr>
				<tr class="info" style="display: none;">
					<td >上传图片</td>
					<td colspan="2">
						<div lab="uploadFile">
						    <input id="f2" type="file" multiple="true">
						    <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
						    <script type="text/javascript">
						        $(function() {
						            $('#f2').uploadify({
						                'formData'     : {//POST数据
						                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
						                },
						                'fileTypeDesc' : '上传文件',//上传描述
						                'fileTypeExts' : '*.jpg;*.png',
						                'swf'      : '{{__PUBLIC__}}/uploadify/uploadify.swf',
						                'uploader' : '{{U('upload')}}',
						                'buttonText':'选择文件',
						                'fileSizeLimit' : '2000KB',
						                'uploadLimit' : 10,//上传文件数
						                'width':65,
						                'height':25,
						                'successTimeout':10,//等待服务器响应时间
						                'removeTimeout' : 0.2,//成功显示时间
						                'onUploadSuccess' : function(file, data, response) {
						                    //转为json
						                    data=$.parseJSON(data);
						                    //获得图片地址
						                    var imageUrl = data.url;
						                    var li="<li><img src='"+imageUrl+"'/><input type='hidden' name='dimg[]' value='"+data.path+"'/></li>";
						                    $("#uploadList ul").prepend(li);
						                }
						            });
						        });
						    </script>
    						<div id="uploadList">
      							<ul>

        						</ul>
    						</div>
						</div>
						
						
					</td>
				</tr>
			</tbody></table>
			{{else}}
			<table class="table table-bordered">
				<tbody><tr>
					<th colspan="3" class="btn btn-primary">商品图册</th>
				</tr>
				<tr class="info">
					<td >上传图片</td>
					<td colspan="2">
						<div lab="uploadFile">
						    <input id="f2" type="file" multiple="true">
						    <span>类型: *.jpg,*.png 大小: 2000KB 数量: 10</span>
						    <script type="text/javascript">
						        $(function() {
						            $('#f2').uploadify({
						                'formData'     : {//POST数据
						                    '<?php echo session_name();?>' : '<?php echo session_id();?>',
						                },
						                'fileTypeDesc' : '上传文件',//上传描述
						                'fileTypeExts' : '*.jpg;*.png',
						                'swf'      : '{{__PUBLIC__}}/uploadify/uploadify.swf',
						                'uploader' : '{{U('upload')}}',
						                'buttonText':'选择文件',
						                'fileSizeLimit' : '2000KB',
						                'uploadLimit' : 10,//上传文件数
						                'width':65,
						                'height':25,
						                'successTimeout':10,//等待服务器响应时间
						                'removeTimeout' : 0.2,//成功显示时间
						                'onUploadSuccess' : function(file, data, response) {
						                    //转为json
						                    data=$.parseJSON(data);
						                    //获得图片地址
						                    var imageUrl = data.url;
						                    var li="<li><img src='"+imageUrl+"'/><input type='hidden' name='dimg[]' value='"+data.path+"'/></li>";
						                    $("#uploadList ul").prepend(li);
						                }
						            });
						        });
						    </script>
    						<div id="uploadList">
      							<ul>

        						</ul>
    						</div>
						</div>
						
						
					</td>
				</tr>
			</tbody></table>
			{{endif}}

			<table class="table">
				<tbody><tr class="next_show">
					<th class="btn btn-primary">商品内容</th>
				</tr>
				<tr class="info">
					<td>
					<!--调用百度编辑器-->
					<script id="editor1" type="text/plain" style="width:100%;height:500px;" name="dcontent">{{$detailData[0]['dcontent']}}</script>
		    		<script>
		        		var ue = UE.getEditor('editor1');
		   			 </script>
					</td>
				</tr>
			</tbody></table>

			<table class="table">
				<tbody><tr class="next_show">
					<th class="btn btn-primary">售后服务</th>
				</tr>
				<tr class="info">
					<td>
						<!--调用百度编辑器-->
						<script id="editor" type="text/plain" style="width:100%;height:500px;" name="dservice">{{$detailData[0]['dservice']}}</script>
		    			<script>
		        			var ue = UE.getEditor('editor');
		  	  			</script>
					</td>
				</tr>
			</tbody></table>
			<input type="hidden" name="type_tid" value="0">
				
			<input type="hidden" name="did" value="{{$detailData[0]['did']}}">
			<input type="hidden" name="gid" value="{{Q('get.gid')}}"/>
			<input type="submit" value="确认修改" class="btn btn-primary btn-block btn-large">
		</fieldset>
	</form>
	<script type="text/javascript">
		$(function(){
			$('[name=classify_cid]').change(function(){
				var tid=$('option:selected').attr('tid');
				//获得type_tid
				$('[name=type_tid]').val(tid);
				$.ajax({
					type:"post",
					url:"{{U('getTypeAttr')}}",
					data:{id:tid},
					dataType:'json',
					success:function(phpData){
						//规格（可选）
						var spec='';
						//属性(不可选)
						var attr='';
						$.each(phpData,function(k,v){
							//规格
							if(v.type==1){
								spec+='<tr class="info">'+
								'<td>'+v.attname+'</td>'+
								'<td>'+
									'<select name="spec['+v.taid+'][price][]" id=""><option value="">请选择</option>';
										$.each(v.attvalue,function(kk,vv){
											spec+='<option value="'+vv+'">'+vv+'</option>';
										});
									spec +='</select></td><td>附加价格：<input type="text" name="spec['+v.taid+'][price][]" id="" /></td>'+'<td><span class="btn btn-success add-spec">増加规格</span></td></>';	
							}else{
								
								
								attr+='<tr class="info">'+
										'<td>'+v.attname+'</td>'+
										'<td>'+
										'<input type="hidden" name="type_tid" value="'+v.taid+'" />'+
										'<select name="attr['+v.taid+']" id=""><option value="">请选择</option>';
										$.each(v.attvalue,function(kk,vv){
											attr+='<option value="'+vv+'">'+vv+'</option>';
										});
								attr +='</select></td></tr>';
							}
						});
						//$.each
						//插入属性
						$('#attr').html(attr);
						$('#spec').html(spec);
					}
					//success
				});
				//ajax
			})
			//异步结束
			//点击添加规格
			$('.add-spec').live('click',function(){
				//找到父级的tr
				var parentsTr=$(this).parents('tr');
				//把父级的tr克隆复制
				var cloneTr=parentsTr.clone();
				cloneTr.find('.add-spec').removeClass('add-spec btn-success').addClass('remove-spec btn-danger').html('删除规格');
				//插入下一行
				parentsTr.after(cloneTr);
			})
			//删除规格
			$('.remove-spec').live('click',function(){
				$(this).parents('tr').remove();
			})
			
			
			
			
			
		})
	</script>
</body>
</html>




























































